the new statement is not in the loop, and neither is the delete. I now see why delete comes before NULL.
Like it says up top, this is the format of the pointer:
Code:
char * szBuffer=new char [256];//have to use pointer for certain functions
...
/*should be
delete [] szBuffer; <--Causes an error when the program closes, one of the last things done before return 0 is this step.
szBuffer=NULL; 
*/
//but i have the following
szBuffer=NULL;//causes memory leak but no error
delete [] szBuffer;
I don't declare static...is that whats causing the problem? that it keeps allocating more and more memory without freeing it all? If declaring static would fix the problem...how would i go about doing it? like so?:
Code:
new static char * szBuffer;//now how do i make it 246 bytes in size?
memory management is not one of my strong points...I've never been taught the do's and don'ts so i play it by ear and end up with these errors, so if you could bear with me that'd be great. thanks.